from PyQt5.Qt import *
from demo_386_MyBtn import MyBtn


class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('demo_388_装饰器连接信号和槽')
        self.resize(500, 500)
        self.setup_ui()
        QMetaObject.connectSlotsByName(self)

    def setup_ui(self):
        btn = MyBtn('test_button', self)
        btn.setObjectName('btn')
        btn.move(100, 100)

    @pyqtSlot()
    def on_btn_rightClicked(self):
        print('右键信号被触发了')

    @pyqtSlot(bool)
    def on_btn_clicked(self, pressed):
        print('xxx', pressed)

    @pyqtSlot(str)
    def on_btn_signalWithParam(self, val):
        print('signalWithParam:', val)

    @pyqtSlot(str)
    def on_btn_signal_with_param(self, val):
        print('signal_with_param:', val)


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)

    win = Window()
    win.show()

    sys.exit(app.exec_())
